package com.saltlux.tdd.algorithm;

import java.util.Random;

import org.junit.Assert;
import org.junit.Test;

public class SelectionSortTester {
	@Test
	public void simpleTest() {
		int[] fixture = new int[] { 3, 2, 1 };
		SelectionSort sort = new SelectionSort();
		sort.sort(fixture);

		Assert.assertEquals(1, fixture[0]);
		Assert.assertEquals(2, fixture[1]);
		Assert.assertEquals(3, fixture[2]);
	}

	@Test
	public void complexTest() {
		int[] fixture = new int[] { 6, 2, 3, 1, 7, 0, 4 };
		SelectionSort sort = new SelectionSort();
		sort.sort(fixture);

		Assert.assertArrayEquals(new int[] { 0, 1, 2, 3, 4, 6, 7 }, fixture);
	}

	@Test
	public void complexTest1() {
		int[] fixture = new int[] { 0, 2, 3, 1, 7, 0, 4 };
		SelectionSort sort = new SelectionSort();
		sort.sort(fixture);

		Assert.assertArrayEquals(new int[] { 0, 0, 1, 2, 3, 4, 7 }, fixture);
	}

	@Test
	public void bigArrayTest() {
		int[] fixture = new int[10000];
		Random random = new Random();
		for (int i = 0; i < fixture.length; i++) {
			fixture[i] = random.nextInt();
		}

		long start = System.currentTimeMillis();
		SelectionSort sort = new SelectionSort();
		sort.sort(fixture);
		long end = System.currentTimeMillis();

		System.out.println(end - start);
	}
	
	@Test
	public void stringArrayTest() {
		String[] fixture = new String[]{"b", "a", "c"};
	
		SelectionSort sort = new SelectionSort();
		sort.sort(fixture);

		Assert.assertArrayEquals(new String[]{"a", "b", "c"}, fixture);
	}
	@Test
	public void doubleObjectArrayTest(){
		Double[] fixture = new Double[]{1.2,3.5,5.6};
		
		SelectionSort sort = new SelectionSort();
		sort.sort(fixture);
		
		Assert.assertArrayEquals(new Double[]{1.2,3.5,5.6}, fixture);
	}
}
